/*
 * Copyright © 2017 eqxiu.com 北京中网易企秀科技有限公司  All rights reserved.
 */

package cn.hermit.pagination;

import java.io.Serializable;
import java.util.List;

/**
 * @author JackGao 高建国
 * @description //TODO 设计说明
 * @date 12/5/2017
 */
public class PageDTO<T> implements Serializable {

    private static final long serialVersionUID = -7870044768796304513L;

    private List<T> dataList;

    //from 1
    private int pageNo;

    private int pageSize;

    private long total;

    private boolean end;

    private PageDTO() {

    }

    public static <T> PageDTO<T> create(List<T> dataList, long total, int pageNo, int pageSize) {
        PageDTO<T> pageDTO = new PageDTO<>();
        pageDTO.dataList = dataList;
        pageDTO.pageNo = pageNo;
        pageDTO.pageSize = pageSize;
        pageDTO.total = total;
        if(pageSize * pageNo >= total) {
            pageDTO.end = true;
        }
        return pageDTO;
    }

    public List<T> getDataList() {
        return dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public boolean isEnd() {
        return end;
    }

    public void setEnd(boolean end) {
        this.end = end;
    }
}
